document.write('<script src="/scripts/jquery.min.js"></script><script src="/scripts/upload/webuploader.min.js"></script>');


var SystemGlobal = {
    defaultEmptyImgSrc: "https://cmp520.oss-cn-shenzhen.aliyuncs.com/default/empty.jpg"
}

String.prototype.URLQuery = function (name) {
    var reg = new RegExp("(^|&|\\?)" + name + "=([^&]*)(&|$)", "i");
    var r;
    try {
        r = unescape(this.slice().match(reg)[2]);
    } catch (e) {
        r = null;
    }
    if (r != null) return unescape(r);
    return null;
}

var $http = {
    send: function (url, data, sfun, opts) {
        var baseURL = "http://192.168.50.69/";
        url = baseURL + url;
        var _opst = Object.assign({
            url: url,
            method: "post",
            headers: { "Authorization": "2222" },
            data: data,
            timeout: 30000,
            loading: {
                sw: true,
                msg: '加载中'
            }
        }, opts);
        var _axios = axios.create(_opst);
        _axios.interceptors.request.use(config => {
            if (_opst.loading.sw) {
                HeyUI.$Loading(_opst.loading.msg);
            }
            return config;
        }, error => {
            return Promise.reject(error);
        });
        _axios.request(_opst).then(res => {
            if (_opst.loading.sw) {
                HeyUI.$Loading.close();
            }
            var _data = res.data;
            if (res.status == 200) {
                if (_data.Code == 40001) { //无权限访问

                    return;
                }
                if (res.data.Code == 40002) { //未登陆

                    return;
                }
                sfun(_data.Data, _data.Code, _data.Msg);
                return;
            }
            HeyUI.$Modal({
                title: '警告',
                content: '系统发生了错误,请联系管理员'
            });
        }).catch(err => {
        });
    },
    post: function (url, data, sfun, opts) {
        this.send(url, data, sfun, opts);
    },
    get: function (url, sfun, opts) {
        opts = Object.assign({
            method: "get"
        }, opts);
        this.send(url, "", sfun, opts);
    },
    /**请求表格分页数据 */
    tablePageData: function (url, data, sfun, opts) {
        this.post(url, data, function (data) {
            var _data = data.Data;
            var _page = {
                page: data.PageIndex,
                size: data.PageSize,
                total: data.DataCount
            };
            sfun({ data: _data, page: _page });
        }, opts);
    },
    /**通用删除数据*/
    delete: function (url, data, sfun) {
        HeyUI.$Confirm('是否删除选中项？').then(() => {
            this.post(url, data, function (d, code, msg) {
                if (code == 0) {
                    var s = sfun(true);
                    if (s) {
                        HeyUI.$Message.success(msg);
                    }
                    return;
                };
                HeyUI.$Message.error(msg);
            })

        }).catch(() => { });
    },
    /**通用 添加 or 修改*/
    insertOrUpdate(url, data) {
        $http.post(url, data, function (data, code, msg) {
            if (code == 0) {
                HeyUI.$Confirm(msg + ' 是否返回').then(() => {
                    window.history.back(-1);
                }).catch(() => {

                });
                return;
            }
            HeyUI.$Message.error(msg);
        });
    }
}

Vue.prototype.$url = {
    query(name) {
        return window.location.href.URLQuery(name);
    }
}

Vue.prototype.$Alert = function (content, sfun) {
    HeyUI.$Modal({
        title: '提示',
        content: content,
        buttons: [{
            type: 'ok',
            name: '确认',
            color: 'primary'
        }],
        events: {
            ok: (modal) => {
                if (sfun) {
                    sfun(true);
                }
                modal.close();
            }
        }
    });
}

Vue.component('table-service', {
    props: {
        url: String,
        parms: {
            type: Object,
            default: {}
        }
    },
    template: `<div><div class="page-data"><slot></slot></div>
            <div class="page-data-page">
                <h-pagination v-model="page" @change="pageChange"></h-pagination>
            </div></div>`,
    data() {
        return {
            page: {
                page: 1,
                size: 10,
                total: 100
            },
            queryParms: {}
        }
    },
    methods: {
        loadData: function () {
            var _this = this;
            var pages = {
                Page: {
                    Index: _this.page.page,
                    Size: _this.page.size
                }
            };
            _this.queryParms = _this.parms;
            var _parms = Object.assign(_this.queryParms, pages);
            var _url = _this.url;
            $http.tablePageData(_url, _parms, function (d) {
                _this.page = d.page;
                _this.$emit('onchange', d.data);
            })
        },
        pageChange: function (value) {
            this.page.page = value.page;
            this.page.size = value.size;
            this.page.total = value.total;
            this.loadData();
        }
    },
    mounted: function () {
        this.loadData();
    }
    //,
    // watch: {
    //     parms: function (newVal, oldVal) {
    //         console.log("新值");
    //         console.log(newVal);
    //         console.log(oldVal);
    //         this.queryParms = newVal;  //newVal即是chartData
    //         this.loadData();
    //     }
    // }
})

Vue.component('page-header', {
    props: {
        title: {
            type: String,
            default: ""
        }
    },
    template: `<div class="page-title">
    <h-row>
        <h-cell width="12">
            <h5 class="page-title-text">{{title}}</h5>
        </h-cell>
        <h-cell width="12">
            <div class="float-right">
                <h-button icon="h-icon-refresh" @click="onRefresh" v-tooltip placement="left" theme="white" content="刷新当前页面"></h-button>
            </div>
        </h-cell>
    </h-row>
</div>`,
    methods: {
        onRefresh() {
            location.reload();
        }
    }
})

Vue.component('button-history', {
    template: `<h-button @click="back">返回</h-button>`,
    methods: {
        back() {
            window.history.back(-1);
        }
    }
})

//多图组件
Vue.component('image-list', {
    template: ` <div class="images-control">
        <div class="images-control-btns" v-if="number>1">
            <h-button-group>
                <h-button text-color="primary" no-border icon="h-icon-plus" theme="white" v-tooltip content="添加一张图片"
                    @click="onAdd">添加</h-button>
                <h-button no-border text-color="red" icon="h-icon-refresh" theme="white" v-tooltip content="清空所有图片"
                 @click="onReset">重置</h-button>
            </h-button-group>
            <div class="images-control-tip gray-color">最多可以添加{{number}}张图片</div>
        </div>
        <div class="images-control-content">
            <draggable v-model="imgs" tag="ul" animation="300" handle=".image-list-header" :class="['image-list']" >
                <li v-for="(item, index) in imgs" :key="index" @mouseenter="onSenter(index)" @mouseleave="onleavue(index)">
                    <transition name="fade-in-down">
                    <div class="image-list-header" v-if="sort && number>1" v-show="item.tool">
                        <i class="icon icon-tuodong"></i>
                        拖动排序
                    </div>
                    </transition>
                    <div class="image-list-content">
                        <img :src="item.src" alt="" :style="{ width: width + 'px', height: height + 'px','border-radius':borderRadius }">
                    </div>
                    <transition name="fade-in-up">
                    <div class="image-list-footer" v-if="sort" v-show="item.tool">
                        <div @click="onEdit(index)">
                            <button style="color: #fff;"
                                class="h-btn h-btn-no-border h-btn-text-primary h-btn-transparent h-btn-block h-btn-s"><i
                                    class="h-icon-edit" ></i></button>
                        </div>
                        <div @click="onDelete(index)" v-if="number>1">
                            <button style="color: #fff;"
                                class="h-btn h-btn-no-border h-btn-text-red h-btn-transparent h-btn-block h-btn-s"><i
                                    class="h-icon-trash" ></i></button>
                        </div>
                    </div>
                    </transition>
                </li> 
            </draggable>
            <div class="gray-color">{{helpText}}</div>
        </div>
    </div>`,
    props: {
        width: {
            type: Number,
            default: 200
        },
        height: {
            type: Number,
            default: 150
        },
        sort: {
            type: Boolean,
            default: true
        },
        number: {
            type: Number,
            default: 2
        },
        helpText: {
            type: String,
            default: ""
        },
        borderRadius: {
            type: String,
            default: "0px"
        },
        datas: {
            type: String,
            default: ""
        }
    },
    model: {
        prop: 'datas',
        event: 'change'
    },
    data() {
        return {
            imgs: []
        }
    },
    methods: {
        initData() {
            let _this = this;
            //如果是空值默认给一个地址
            if (_this.datas == "") {
                _this.addDefaultEmpty();
            }
            return;
            var imgArray = _this.datas.split(',');
            imgArray.forEach(img => {
                _this.imgs.push({
                    src: img,
                    tool: false,
                    default: false
                });
            })

        },
        addDefaultEmpty() { //添加默认空图片
            this.imgs.push({
                src: SystemGlobal.defaultEmptyImgSrc,
                tool: false,
                default: true
            });
        },
        onAdd() { //添加图片
            var _this = this;
            var leng = _this.imgs.length;
            if (leng >= _this.number) {
                HeyUI.$Message.info(`添加图片不能超过${_this.number}张`);
                return;
            }

            //计算剩下数量
            var mult = _this.number - leng;
            this.$uploaderManage({
                multiple: mult
            }, function (imgSrc) {
                imgSrc.forEach(src => {
                    _this.imgs.push({
                        src: src,
                        tool: false,
                        default: false
                    });
                });
            });
        },
        onReset() {
            this.imgs = [];
            this.addDefaultEmpty();
        },
        onEdit(index) {
            var _this = this;
            this.$uploaderManage({
                multiple: 1
            }, function (imgSrc) {
                var item = {
                    src: imgSrc[0],
                    tool: false,
                    default: false
                };
                _this.imgs.splice(index, 1, item);
            });
        },
        onDelete(index) {
            this.imgs.splice(index, 1);
        },
        onSenter(i) {
            this.imgs[i].tool = true;
        },
        onleavue(i) {
            this.imgs[i].tool = false;
        }
    },
    watch: {
        imgs: function (newValue) {
            let value = newValue.filter(f => f.default == false);
            this.$emit('change', value.map(m => m.src).join(','));
        }
    },
    mounted() {
        this.initData();
    }
})

//上传管理
Vue.prototype.$uploaderManage = function (opts, sfun) {
    let _defaultOpts = {
        fileNum: 1,
        fileSize: 300 * 1024,
        fileSingleSize: 300 * 1024,
        multiple: 1,
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        }
    };
    opts = Object.assign(_defaultOpts, opts);

    let directoryExtend = Vue.extend({
        template: `<div style="padding:15px">
            <div class="h-modal-header">新建文件夹</div>
                <div>
                    <h-form v-width="460" :label-width="110" :model="model" :rules="validation" ref="form"
                        :top="0.2" show-error-tip>
                        <h-form-item label="文件夹名称" prop="name">
                            <input type="text" v-model="model.name" placeholder="只允许英文字母" />
                        </h-form-item>
                    </h-form>
                </div>
                 <div class="h-modal-footer">
                    <h-button color="primary" @click="submit">保存</h-button>
                    <button class="h-btn" @click="close">取消</button>
                </div>
            </div>`,
        data() {
            return {
                model: {
                    name: ""
                },
                validation: {
                    required: [
                        'name'
                    ],
                    rules: {
                        name: {
                            valid: {
                                pattern: /^[a-z]+$/i,
                                message: '只能由英文字母组成,可以是拼音'
                            }
                        }
                    }
                },
            }
        },
        methods: {
            submit() {
                let _this = this;
                let validResult = _this.$refs.form.valid();
                if (!validResult.result) {
                    return;
                }
                //添加目录
                $http.post("file/createDirectory", _this.model, function (d, code, msg) {
                    if (code == 0) {
                        _this.$emit("succeed");
                    }
                    HeyUI.$Message(msg);
                })
            },
            close() {
                this.$emit("close");
            }
        }
    })

    let uploaderExtend = Vue.extend({
        template: `<div class="file-manage">
        <h-layout>
            <h-sider>
                <h-loading text="Loading" :loading="loading.directory"></h-loading>
                <div class="file-manage-dire">
                    <div class="create-btn">
                        <h-button noBorder text-color="primary" icon="h-icon-plus" @click="createDirectory">新建文件夹</h-button>
                    </div>
                    <div class="file-manage-dire-content">
                        <h-tabs class-name="h-tabs-menu file-manage-dire-tabs" :datas="fileDirectory"
                            key-name="key" title-name="name" v-model="fileDirectorySelected"
                            @change="onChangeDirectory">
                            <template slot-scope="{tab}" slot="item">
                                <span><i class="icon icon-wenjian1"></i></span>
                                <span>{{tab.name}}</span>
                            </template>
                        </h-tabs>
                    </div>
                    <div class="dire-title">
                     <div v-show="typeSelected==1">允许选择数量：{{multiple}}</div>
                      <div v-show="typeSelected==2">
                        <div>上传总数量：{{fileNum}}</div>
                        <div>单文件大小：{{fileSingleSizeLimitKB}}</div>
                        <div>总文件大小：{{fileSizeLimitKB}}</div>
                      </div>
                    </div>
                </div>
            </h-sider>
            <h-layout>
                <h-header>
                    <div class="file-manage-header">
                        <h-tabs class-name="h-tabs-card" :datas="fileType" key-name="key" title-name="name"
                            v-model="typeSelected" @change="onChangeType">
                        </h-tabs>
                    </div>
                </h-header>
                <h-content>
                    <div class="file-manage-content">
                        <div class="online" v-show="typeSelected==1" @scroll="onOnlineScroll($event)">
                         <h-loading text="Loading" :loading="loading.file"></h-loading>
                            <div class="uploader-list">
                                <div class="uploader-list-item" v-for="(item, index) in online.file"
                                    :key="index" @click="onOnlineSelected(index)">
                                    <img :src="item.src">
                                    <div class="select-btn" v-show="item.checked">
                                        <i class="h-icon-check"></i>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="uploader" v-show="typeSelected==2">
                            <div class="uploader-list">
                                <div class="uploader-list-item" v-for="(item, index) in fileListData"
                                    :key="index" @mouseenter="onSenter(index)" @mouseleave="onleavue(index)">
                                    <div class="uploader-list-item-btn" v-show="item.closeBtnShow"
                                        v-if="item.errorCode!=1">
                                        <span class="close" title="移除" @click="onRemoveFile(item.id,index)"><i
                                                class="h-icon-trash"></i></span>
                                    </div>
                                    <div class="uploader-list-item-title"
                                        :class="[item.errorCode==2 ? 'error':'']" v-show="item.errorCode>0">
                                        {{item.errorMsg}}
                                    </div>
                                    <img :src="item.src">
                                    <div class="uploader-list-item-file-progress">
                                        <h-progress :percent="item.progress" color="#45B984" :stroke-width="6">
                                        </h-progress>
                                    </div>
                                    <div class="uploader-list-item-file-size">{{item.size}}</div>
                                    <div class="uploader-list-item-file-name text-ellipsis" :title="item.name">
                                        {{item.name}}</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </h-content>
                <h-footer>
                    <div class="file-manage-upload-btns">
                        <span v-show="typeSelected==2">
                            <button id="uploader_drop" ref="uploader_drop" class="h-btn h-btn-primary"><i
                                    class="h-icon-plus"></i>&nbsp;<span>添加</span></button>
                            <h-button icon="h-icon-upload" @click="onUploader">上传</h-button>
                        </span>
                        <span v-show="typeSelected==1">
                            <h-button color="primary" icon="h-icon-check" @click="onOnlineConfirm">确定</h-button>
                        </span>
                        <h-button @click="onClose" icon="h-icon-close">取消</h-button>
                    </div>
                </h-footer>
            </h-layout>
        </h-layout>
    </div>
</div>`,
        props: {
            fileNum: { //文件数量
                type: Number,
                default: 1
            },
            fileSize: { //文件大小
                type: Number,
                default: 300 * 1024
            },
            fileSingleSize: { //文件单个大小
                type: Number,
                default: 300 * 1024
            },
            multiple: { //允许多图选中最大数量
                type: Number,
                default: 1
            },
            accept: { //限制文件类型
                type: Object,
                default: {
                    title: 'Images',
                    extensions: 'gif,jpg,jpeg,bmp,png',
                    mimeTypes: 'image/*'
                }
            }
        },
        data() {
            return {
                open: true,
                uploader: null,
                thumbConfig: {
                    url: "/scripts/upload/img/",
                    ico: [
                        { ec: ["txt"], img: "txt.png" },
                        { ec: ["rar", "zip", "iso"], img: "zip.png" },
                        { ec: ["wav", "wma", "ogg", "ape", "acc"], img: "audio.png" },
                        { ec: ["avi", "rmvb", "rm", "flash", "mp4", "3gp"], img: "video.png" },
                        { ec: ["exe"], img: "exe.png" },
                        { ec: ["mp3"], img: "mp3.png" },
                        { ec: ["ppt", "pptx"], img: "ppt.png" },
                        { ec: ["doc", "docx"], img: "word.png" },
                        { ec: ["xls", "xlsx"], img: "execl.png" }
                    ]
                },
                fileType: [
                    {
                        key: 1,
                        name: "图片管理",
                    },
                    {
                        key: 2,
                        name: "文件上传",
                    }
                ],
                fileDirectory: [],
                createDirectoryModal: true,
                fileDirectorySelected: "pic",
                typeSelected: 1,
                fileListData: [],
                online: { //在线图片
                    file: [],
                    fileNextMarker: "",
                    multiple: this.multiple
                },
                fileNumLimit: this.fileNum,
                fileSizeLimit: this.fileSize,
                fileSingleSizeLimit: this.fileSingleSize,
                uploaderAccept: this.accept,
                fileSizeLimitKB: "",
                fileSingleSizeLimitKB: "",
                loading: {
                    directory: true,
                    file: true
                }
            }
        },
        methods: {
            //创建
            create() {
                var _this = this;
                _this.uploader = WebUploader.create({
                    server: 'http://192.168.50.69/file/upload',
                    //选择文件的按钮。可选。
                    pick: _this.$refs.uploader_drop,// '#uploader_drop',
                    formData: { dirName: "pic" },
                    compress: false, //不压缩
                    fileNumLimit: _this.fileNumLimit, // 验证文件总数量, 超出则不允许加入队列。
                    fileSizeLimit: _this.fileSizeLimit, // 验证文件总大小是否超出限制, 超出则不允许加入队列。
                    fileSingleSizeLimit: _this.fileSingleSizeLimit, // 验证单个文件大小是否超出限制, 超出则不允许加入队列
                    accept: _this.uploaderAccept
                });

                //当文件添加到上传队列后触发
                _this.uploader.on('filesQueued', function (files) {
                    files.forEach(file => {
                        var size = WebUploader.Base.formatSize(file.size, 0, ['B', 'KB', 'MB']);
                        // 创建缩略图
                        _this.uploader.makeThumb(file, function (error, src) {
                            if (error) {
                                _this.fileListData.push({
                                    id: file.id,
                                    src: _this.thumbSrc(file.ext),
                                    name: file.name,
                                    size: size,
                                    progress: file.processed,
                                    closeBtnShow: false,
                                    progress: 0,
                                    errorCode: 0,
                                    errorMsg: ""
                                });
                                return;
                            }
                            _this.fileListData.push({
                                id: file.id,
                                src: src,
                                name: file.name,
                                size: size,
                                progress: file.processed,
                                closeBtnShow: false,
                                progress: 0,
                                errorCode: 0,
                                errorMsg: ""
                            });
                        }, 118, 118);

                    })

                });

                //上传前触发
                _this.uploader.on("uploadBeforeSend", function (obj, data, headers) {
                    data.dirName = _this.fileDirectorySelected;
                })

                //上传过程中触发，携带上传进度。
                _this.uploader.on("uploadProgress", function (file, percentage) {
                    var progress = percentage * 100;
                    if (progress >= 100) {
                        progress = 100;
                    }
                    _this.fileListData.find(f => f.id == file.id).progress = progress;
                })

                // 上传错误
                _this.uploader.on("uploadError", function (file, reason) {
                    let data = _this.fileListData.find(f => f.id == file.id);
                    data.errorMsg = "上传失败";
                    data.errorCode = 2;
                })

                //上传成功
                _this.uploader.on("uploadSuccess", function (file, response) {
                    let data = _this.fileListData.find(f => f.id == file.id);
                    data.errorMsg = "上传成功";
                    data.errorCode = 1;
                    _this.$emit('onsuccee', [response.Data.Url], 2);
                })

                //当validate不通过时以派送错误事件的形式通知调用者。通过
                _this.uploader.on("error", function (type) {
                    let msg = "";
                    switch (type) {
                        case "Q_EXCEED_NUM_LIMIT":
                            msg = "超出文件总数量";
                            break;
                        case "Q_EXCEED_SIZE_LIMIT":
                            msg = "添加的文件过大";
                            break;
                        case "F_EXCEED_SIZE":
                            msg = "添加的文件过大";
                            break;
                        case "Q_TYPE_DENIED":
                            msg = "不支持该类型文件";
                            break;
                    }
                    HeyUI.$Message.error(msg);
                })
            },
            //获取文件扩展预览图片
            thumbSrc(name) {
                var img = "file.png";
                this.thumbConfig.ico.forEach(item => {
                    var icon = item.ec.find(f => f == name);
                    if (icon) {
                        img = item.img;
                    }
                })
                return this.thumbConfig.url + img;
            },
            onSenter(index) {
                this.fileListData[index].closeBtnShow = true;
            },
            onleavue(index) {
                this.fileListData[index].closeBtnShow = false;
            },
            onUploader() { //上传
                this.uploader.upload();
            },
            onRemoveFile(id, index) { //移除上传文件
                this.uploader.removeFile(id, true);
                this.fileListData.splice(index, 1);
            },
            onChangeType(data) { //操作类型改变
                //console.log(data);
            },
            onOnlineSelected(index) { //在线管理选中文件切换
                //可能只选中一张
                var ck = this.online.file[index].checked;
                if (ck) {
                    ck = false;
                } else {
                    ck = true;
                }

                //选中当前判断
                if (ck) {
                    var ml = this.online.multiple;
                    var count = this.online.file.filter(f => f.checked == true).length;
                    if (count >= ml) {
                        return;
                    }
                }
                this.online.file[index].checked = ck;
            },
            onOnlineConfirm() { //在线管理确定选中图片
                var data = this.online.file.filter(f => f.checked == true);
                var srcs = [];
                if (data.length > 0) {
                    srcs = data.map(m => m.src);
                }
                this.$emit('onsuccee', srcs, 1);
            },
            onOnlineScroll(e) {
                if (e.target.scrollHeight - e.target.scrollTop === e.target.clientHeight) {
                    this.loadFile();
                }
            },
            onChangeDirectory() { //改变目录清空加载文件重新加载指定文件夹
                this.online.file = [];
                this.online.fileNextMarker = "";
                this.loadFile();
            },
            //加载目录
            loadDirectory() {
                var _this = this;
                _this.loading.directory = true;
                $http.post("file/directoryList", {}, function (d) {
                    let _data = [];
                    d.DirData.forEach(item => {
                        _data.push({
                            key: item,
                            name: item
                        })
                    });
                    _this.fileDirectory = _data;
                    _this.loading.directory = false;
                }, { loading: { sw: false } })
            },
            //加载文件
            loadFile() {
                let _this = this;
                //没有数据加载
                if (_this.online.fileNextMarker == null) {
                    return;
                }
                var postData = {
                    Marker: _this.online.fileNextMarker,
                    DirName: _this.fileDirectorySelected
                };
                _this.loading.file = true;
                $http.post("file/fileList", postData, function (d) {
                    d.Url.forEach(item => {
                        _this.online.file.push({
                            src: item,
                            checked: false
                        })
                    });
                    _this.online.fileNextMarker = d.NextMarker;
                    _this.loading.file = false;
                }, { loading: { sw: false } })
            },
            formatKB() {
                this.fileSingleSizeLimitKB = WebUploader.Base.formatSize(this.fileSingleSizeLimit, 0, ['B', 'KB', 'MB']);
                this.fileSizeLimitKB = WebUploader.Base.formatSize(this.fileSizeLimit, 0, ['B', 'KB', 'MB']);
            },
            onClose() {
                this.$emit("onclose");
            },
            createDirectory() {
                var _this = this;
                this.$Modal({
                    component: {
                        vue: directoryExtend
                    },
                    events: {
                        succeed(modal) {
                            _this.loadDirectory();
                        },
                        close(modal) {
                            modal.close();
                        }
                    }
                })

            }

        }, mounted() {
            this.loadDirectory();
            this.loadFile();
            this.create();
            this.formatKB();
        }
    });
    this.$Modal({
        className: "uploader-modal",
        transparent: true,
        closeOnMask: false,
        hasCloseIcon: true,
        component: {
            vue: uploaderExtend,
            datas: opts // 子组件直接使用 props 即可使用，兼容性 1.15.0+
        },
        events: {
            onsuccee(modal, src, type) {
                sfun(src);
                if (type == 1) {
                    modal.close();
                }
            },
            onclose(modal) {
                modal.close();
            }
        }
    });
};

